Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet export: Derive a private key for mnemonic accounts #137

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

matevz
Copy link
Member

@matevz matevz commented Oct 2, 2023

Implements #51.

For user:

  • oasis wallet show also prints wallet kind (e.g. file (ed25519-adr8:3)
  • oasis wallet export, if the account is of mnemonic type, also derives the corresponding private key and shows it. This is useful for dApp developers where they need a specific private key to sign the contract create/call transactions

Internal refactorings:

  • test account factory was added for consistency with file and ledger kinds.
  • copies of accountConfig used by wallet/file/file.go, wallet/ledger/ledger.go and wallet/test/test.go were consolidated into shared AccountConfig and moved into wallet.

Before:

$ oasis wallet export TestEd
WARNING: Exporting the account will expose secret key material!
Unlock your account.
? Passphrase: 
Name:             TestEd
Public Key:       RWAfdhrxfbpQJDUp5ilzLxxY0I/92qhJEjhUBHVynYU=
Native address:   oasis1qqjkrr643qv7yzem6g4m8rrtceh42n46usfscpcf
Export:
equip will roof matter pink blind book anxiety banner elbow sun young

$ oasis wallet export TestSecp
WARNING: Exporting the account will expose secret key material!
Unlock your account.
? Passphrase: 
Name:             TestEth
Public Key:       A4MYU1tUEF1Keq5gwI/EX5aHGBtP38YlvRp1P6c5f+11
Ethereum address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Native address:   oasis1qpwyqlu69ga9nzz0xsm0y5j2lr3l52280gdqpkzf
Export:
test test test test test test test test test test test junk

$ oasis wallet export TestSr
WARNING: Exporting the account will expose secret key material!
Unlock your account.
? Passphrase: 
Name:             TestSr
Public Key:       skCcMfU7D0olbxZtn8lLn0u41rJzxiCw7rcv3uVEw3Y=
Native address:   oasis1qz3sz6s86k9l3hlk78s25x29esn5qq43rvrkrgey
Export:
equip will roof matter pink blind book anxiety banner elbow sun young

$ oasis wallet export test:alice
WARNING: Exporting the account will expose secret key material!
Name:             test:alice
Public Key:       NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
Native address:   oasis1qrec770vrek0a9a5lcrv0zvt22504k68svq7kzve
Export:
OPYg5hO22BvHgHmtjo/dZgyn/+efqDhcAfcZ6NsMKhc1w/M1bdhTZP66A1S1Ra2hCdG9s4v11hJoF9uMcs/WkQ==

After:

$ oasis wallet export TestEd
WARNING: Exporting the account will expose secret key material!
Unlock your account.
? Passphrase: 
Name:             TestEd
Kind:             file (ed25519-adr8:0)
Public Key:       RWAfdhrxfbpQJDUp5ilzLxxY0I/92qhJEjhUBHVynYU=
Native address:   oasis1qqjkrr643qv7yzem6g4m8rrtceh42n46usfscpcf
Secret mnemonic:
equip will roof matter pink blind book anxiety banner elbow sun young
Derived secret key for account number 0:
TpyhpMLtkMkNqT6hgVV++fRl9ETAt9412ushj5OQ2YVFYB92GvF9ulAkNSnmKXMvHFjQj/3aqEkSOFQEdXKdhQ==

$ oasis wallet export TestSecp
WARNING: Exporting the account will expose secret key material!
Unlock your account.
? Passphrase: 
Name:             TestSecp
Kind:             file (secp256k1-bip44:0)
Public Key:       A4MYU1tUEF1Keq5gwI/EX5aHGBtP38YlvRp1P6c5f+11
Ethereum address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Native address:   oasis1qpwyqlu69ga9nzz0xsm0y5j2lr3l52280gdqpkzf
Secret mnemonic:
test test test test test test test test test test test junk
Derived secret key for account number 0:
ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

$ oasis wallet export TestSr
WARNING: Exporting the account will expose secret key material!
Unlock your account.
? Passphrase: 
Name:             TestSr
Kind:             file (sr25519-adr8:3)
Public Key:       skCcMfU7D0olbxZtn8lLn0u41rJzxiCw7rcv3uVEw3Y=
Native address:   oasis1qz3sz6s86k9l3hlk78s25x29esn5qq43rvrkrgey
Secret mnemonic:
equip will roof matter pink blind book anxiety banner elbow sun young
Derived secret key for account number 3:
zxVO/G3spH1IAlRbuUFgqaUR3Zv8N+1FblnYvQ0tewq/dI+++j/jvEQ7Ym9wlRVjgHwKW1IOjJpKqgkN+7IyjQ==

$ oasis wallet export test:alice
WARNING: Exporting the account will expose secret key material!
Name:             test:alice
Kind:             test (ed25519-raw)
Public Key:       NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
Native address:   oasis1qrec770vrek0a9a5lcrv0zvt22504k68svq7kzve
Secret key:
OPYg5hO22BvHgHmtjo/dZgyn/+efqDhcAfcZ6NsMKhc1w/M1bdhTZP66A1S1Ra2hCdG9s4v11hJoF9uMcs/WkQ==

@matevz matevz force-pushed the matevz/feature/walletinfo branch from b6301dc to 462e9f2 Compare October 13, 2023 22:06
@matevz matevz force-pushed the matevz/feature/walletinfo branch 5 times, most recently from 23d3fe5 to ac06fc7 Compare December 22, 2023 08:29
@matevz matevz marked this pull request as ready for review December 22, 2023 08:29
@matevz matevz requested a review from kostko December 22, 2023 08:29
@matevz matevz changed the title wallet: Export secp256k1 private key for BIP44 accounts wallet export: Derived a private key for mnemonic accounts Dec 22, 2023
@matevz matevz changed the title wallet export: Derived a private key for mnemonic accounts wallet export: Derive a private key for mnemonic accounts Dec 22, 2023
@matevz matevz force-pushed the matevz/feature/walletinfo branch from ac06fc7 to 1803dfd Compare December 22, 2023 08:38
wallet/wallet.go Outdated Show resolved Hide resolved
wallet/wallet.go Show resolved Hide resolved
wallet/wallet.go Outdated Show resolved Hide resolved
wallet/file/sr25519_test.go Show resolved Hide resolved
wallet/file/secp256k1.go Outdated Show resolved Hide resolved
@matevz matevz force-pushed the matevz/feature/walletinfo branch from 1803dfd to 169054e Compare December 22, 2023 12:20
@matevz matevz requested a review from kostko December 22, 2023 12:20
@matevz matevz force-pushed the matevz/feature/walletinfo branch from 169054e to e0f3f92 Compare January 4, 2024 10:23
@matevz matevz merged commit def2114 into master Jan 4, 2024
3 checks passed
@matevz matevz deleted the matevz/feature/walletinfo branch January 4, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants